package com.easywb.producer.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.easywb.api.SendMessageInterface;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.gson.GsonBuilderCustomizer;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;

// 发送消息接口
@RestController
public class SendMsgController {

	@Autowired
	private SendMessageInterface sendMessageInterface;

	@RequestMapping("/sendMsg")
	public String sendMsg() {
//		String msg = "1111";
        JSONObject msg = new JSONObject();
        msg.put("sa","sasa");
        Message build = MessageBuilder.withPayload(msg.toJSONString().getBytes()).build();
		sendMessageInterface.sendMsg().send(build);
		return "success";
	}

    @RequestMapping("/my_testns")
    public String my_testns() {
		String msg = "1111666";
        Message build = MessageBuilder.withPayload(msg.getBytes()).build();
        sendMessageInterface.sendTestns().send(build);
        return "successmy_testns";
    }
}
